from unittest import TestCase

from effort_metrics.refunds import is_return_worth_it


class TestRefunds(TestCase):
    def test_is_return_worth_it_for_chad(self):
        # Example values
        purchase_price = 50.0  # Cost of the item
        shipping_cost = 10.0  # Original shipping cost
        time_spent_hours = 2.0  # Hours spent handling the issue
        hourly_wage = 25.0  # Your equivalent pay rate per hour
        sunk_cost = 5.0  # Emotional/transactional sunk cost estimate
        refund_amount = 60.0  # The expected refund amount for the item
        return_shipping_cost = 8.0  # Cost to ship the item back
        expected = False

        # Checking if returning the item is worthwhile
        result = is_return_worth_it(
            purchase_price,
            shipping_cost,
            time_spent_hours,
            hourly_wage,
            sunk_cost,
            refund_amount,
            return_shipping_cost,
        )
        self.assertTrue(result is expected)

    def test_is_return_worth_it_alternate(self):
        # Example values
        purchase_price = 67.0  # Cost of the item
        shipping_cost = 0.0  # Original shipping cost
        time_spent_hours = 2.0  # Hours spent handling the issue
        hourly_wage = 50.0  # Your equivalent pay rate per hour
        sunk_cost = 5.0  # Emotional/transactional sunk cost estimate
        refund_amount = 57.0  # The expected refund amount for the item
        return_shipping_cost = 0.0  # Cost to ship the item back
        expected = False

        # Checking if returning the item is worthwhile
        result = is_return_worth_it(
            purchase_price,
            shipping_cost,
            time_spent_hours,
            hourly_wage,
            sunk_cost,
            refund_amount,
            return_shipping_cost,
        )
        self.assertTrue(result is expected)

    def test_is_return_worth_it_pass(self):
        # Example values
        purchase_price = 1000.0  # Cost of the item
        shipping_cost = 0.0  # Original shipping cost
        time_spent_hours = 1.0  # Hours spent handling the issue
        hourly_wage = 20.0  # Your equivalent pay rate per hour
        sunk_cost = 0.0  # Emotional/transactional sunk cost estimate
        refund_amount = 1020.0  # The expected refund amount for the item
        return_shipping_cost = 0.0  # Cost to ship the item back
        expected = True

        # Checking if returning the item is worthwhile
        result = is_return_worth_it(
            purchase_price,
            shipping_cost,
            time_spent_hours,
            hourly_wage,
            sunk_cost,
            refund_amount,
            return_shipping_cost,
        )
        self.assertTrue(result is expected)
